<template>
	<view class="programmes">
		<view class="programme" :class="{ 'programme-active': curren === index }" v-for="(item, index) in list"
			:key="item.id" @click="currenChange(index)">
			<view class="month">
				<view class="value">
					<text>{{ item.lease }}</text>
					<text>个月</text>
				</view>
				<view class="label">期数</view>
			</view>
			<view class="prices">
				<view class="value">
					<text>{{ item.rent }}</text>
					<text>元/月</text>
				</view>
				<view class="label">价格</view>
			</view>
			<view class="deposit">
				<view class="value">
					<text>{{ item.deposit }}</text>
					<text>元</text>
				</view>
				<view class="label">押金(可退)</view>
			</view>
			<view class="active" v-if="curren === index">
				<uv-icon name="checkbox-mark" color="#fff"></uv-icon>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		defineProps,
		defineEmits
	} from 'vue'

	defineProps({
		curren: {
			type: Number,
			default: 0
		},
		list: {
			type: Array,
			default: () => []
		}
	})

	const emit = defineEmits(['change'])
	const currenChange = (e) => {
		emit('change', e)
	}
</script>

<style lang="scss" scoped>
	.programmes {
		.programme {
			margin-top: 24rpx;
			display: flex;
			align-items: center;
			border-radius: 16rpx;
			border: 2rpx solid #DDDDDD;
			padding: 30rpx 36rpx;
			position: relative;

			.month {
				width: 170rpx;
			}

			.prices {
				flex: 1;
			}

			.deposit {
				width: 140rpx;
			}

			.value {
				font-size: 24rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;

				text {
					&:first-child {
						font-size: 36rpx;
					}
				}
			}

			.label {
				margin-top: 8rpx;
				font-size: 26rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
			}

			.active {
				position: absolute;
				right: 0;
				bottom: 0;
				width: 46rpx;
				height: 42rpx;
				background: #FF930D;
				border-radius: 20rpx 0rpx 14rpx 0rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				font-weight: bold;
			}

			&-active {
				border-color: #FF930D;
				background: #FFFBF2;

				.value {
					color: #FE592D;
				}
			}
		}
	}
</style>